package com.cancer.biz.hotel.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cancer.biz.hotel.entity.ProjectDetail;
import com.cancer.biz.hotel.entity.query.RequsetHotelListParam;
import com.cancer.biz.hotel.entity.query.ResponseHotelDetailBody;
import com.cancer.biz.hotel.entity.query.ResponseHotelListBean;
import com.cancer.biz.hotel.mapper.ProjectDetailMapper;
import com.cancer.biz.hotel.mapper.ProjectMapper;
import com.cancer.biz.hotel.mapper.ProjectPictureMapper;
import com.cancer.biz.hotel.service.HotelService;
import com.cancer.common.util.MyBatisUtil;
import com.cancer.common.web.PageBean;
import com.cancer.common.web.PagingContext;
@Service
public class HotelServiceImpl implements HotelService {
    @Autowired
    private ProjectMapper projectMapper;
    @Autowired
    private ProjectDetailMapper projectDetailMapper;
    @Autowired
    private ProjectPictureMapper projectPictureMapper;

    @Override
    public PageBean<ResponseHotelListBean> hotelList(RequsetHotelListParam requsetHotelListParam) {
        int hotelCount = projectMapper.selectHotelCount(requsetHotelListParam);
        List<ResponseHotelListBean> hotelList=projectMapper.selectHotelList(PagingContext.calcOffset(), PagingContext.getPageSize(), requsetHotelListParam);
        return MyBatisUtil.paging(hotelList, hotelCount);
    }

    @Override
    public ResponseHotelDetailBody selectHotelDetailById(Long id) {
        List<String> pictureList = projectPictureMapper.selectPictureById(id);
        List<ProjectDetail> detailList = projectDetailMapper.selectHotelDetailByParentId(id);
        ResponseHotelDetailBody responseHotelDetailBody=new ResponseHotelDetailBody();
        responseHotelDetailBody.setDetailList(detailList);
        responseHotelDetailBody.setPictures(pictureList);
        return responseHotelDetailBody;
    }

}
